package com.todo.delicacy.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.delicacy.application.backend.service.RestaurantInfoBackendService;
import com.todo.delicacy.iface.backend.RestaurantInfoBackendIface;
import com.todo.delicacy.iface.backend.request.*;
import com.todo.delicacy.iface.backend.response.QueryRestaurantInfoByConditionResp;
import com.todo.delicacy.iface.backend.response.RestaurantDetailInfoResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/6/7 15:43
 * @description
 */
@RestController
@RequestMapping("/bd/restaurant")
@Tag(name = "餐馆后台处理类", description = "餐馆后台处理类")
public class RestaurantInfoBackendController implements RestaurantInfoBackendIface {

    @Resource
    private RestaurantInfoBackendService restaurantInfoBackendService;
    ;


    @Override
    @Operation(summary = "新增餐馆信息")
    @PostMapping("/insertRestaurantInfo")
    public BizResponse<Boolean> insertRestaurantInfo(@RequestBody InsertRestaurantInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return restaurantInfoBackendService.insertRestaurantInfo(req);
    }

    @Override
    @Operation(summary = "根据id更新餐馆信息")
    @PostMapping("/updateRestaurantInfoById")
    public BizResponse<Boolean> updateRestaurantInfoById(@RequestBody UpdateRestaurantInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return restaurantInfoBackendService.updateRestaurantInfoById(req);
    }

    @Override
    @Operation(summary = "启禁用餐馆信息")
    @PostMapping("/enableRestaurantInfo")
    public BizResponse<Boolean> enableRestaurantInfo(@RequestBody EnableRestaurantInfoReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return restaurantInfoBackendService.enableRestaurantInfo(req);
    }

    @Override
    @Operation(summary = "多条件查询餐馆信息")
    @PostMapping("/queryRestaurantInfoByCondition")
    public BizPageResponse<QueryRestaurantInfoByConditionResp> queryRestaurantInfoByCondition(@RequestBody QueryRestaurantInfoByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return restaurantInfoBackendService.queryRestaurantInfoByCondition(req);
    }

    @Override
    @Operation(summary = "根据id查询餐馆信息")
    @PostMapping("/queryRestaurantInfoById")
    public BizResponse<RestaurantDetailInfoResp> queryRestaurantInfoById(@RequestBody QueryRestaurantInfoByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return restaurantInfoBackendService.queryRestaurantInfoById(req);
    }
}
